<include file="public:headtop" />
<style>
    body{
        background:white;

    }
    #content{
        padding-top:15px;
        background: #ffffed;
        /*padding:10px;
        border-radius: 10px;*/

    }
    #content .order_address_list{
        padding:0px;
        background:none;
        border-width:0px;
        box-shadow: none;
      }

    #header{
        width:100%;
        background-color: #64dce1;
        height:270px;
        text-align:center;
        position:relative;
        color:white;
    }

    #header .title{
        display:block;
        color:white;
        font-size:14px;
        padding-top:30px;

    }

    #header .avatar{
        border-radius: 100px;width:100px;
        margin-top:70px;
        z-index:999;
    }
</style>

<if condition="$order.type eq 'songwo'">
<header id='header'>
    <span class='title'>没钱了，土豪帮帮忙吧！</span>
    <img class='avatar' src="{$user.avatar}" alt=""><br>
    <span class='name'>{$user.username}</span>
</header>

<volist name='order_details' id='item' >
<div class="order_form" style="border-width:0px;background:white;box-shadow:0 0 0">
<p class="num">订单号: {$order.orderId}</p>
<div class="con">
    <p class="ware_pic"><a href="{:u('item/index',array('id'=>$item['itemId']))}" ><img src="{:attach(get_thumb($item['img'], '_b'), 'item')}" height="80" width="80"></a></p>
    <p class="ware_text"><a href="{:u('item/index',array('id'=>$item['itemId']))}">{$item.title}</a><br><span class="attr"></span></p>
    <p class="price">价格: <span>¥{$order.order_sumPrice}</span></p>
    <!-- <p class="amount">数量: <span>{$item.quantity}</span></p>
    <p class="amount"><php>if($item['color']){</php>颜色: <span>{$item['color']}</span><php>}</php><php>if($item['size']){</php>&nbsp;尺码: <span>{$item['size']}</span><php>}</php></p> -->
</div>
</volist>
<div id="content" style="min-height:1px;background:none">
<ul class="submit">
    <php>if ($isPay){</php>
    <li onClick="javascript:weixin_pay();" title="" class="enter">帮他付款</li>
    <php>}else{</php>
    <li onClick="javascript:showCover();" title="" class="enter">喊朋友来付款</li>
    <php>}</php>
</ul>
</div>
<script>
    function weixin_pay(){
        window.location.href = '{$pay_url}';
    }



</script>

<else/>
<div id='content' action="" method="post">

    <if condition="$share_type eq 'send'">
        <div class="p10"><img style='width:100%' src="/static/weixin/images/index/send_bf_title.png" alt=""></div>
        <volist name='order_details' id='item' >
        <div class="order_form" style="padding:0px;margin:0px;border-width:0px;background:none;box-shadow:0 0 0">
        <div class="con">
            <p class="ware_pic"><a href="{:u('item/index',array('id'=>$item['itemId']))}" ><img src="{:attach(get_thumb($item['img'], '_b'), 'item')}" height="80" width="80"></a></p>
            <p class="ware_text"><a href="{:u('item/index',array('id'=>$item['itemId']))}">{$item.title}</a><br><span class="attr"></span></p>
            <p class="price">价格: <span>¥{$order.order_sumPrice}</span></p>
            <!-- <p class="amount">数量: <span>{$item.quantity}</span></p>
            <p class="amount"><php>if($item['color']){</php>颜色: <span>{$item['color']}</span><php>}</php><php>if($item['size']){</php>&nbsp;尺码: <span>{$item['size']}</span><php>}</php></p> -->
            
        </div>
        </volist>
        <div id="content" style="min-height:1px;padding:15px">
            <ul class="submit">
                <li onClick="showCover()" title="" class="enter">送给Ta</li>
            </ul>
        </div>



    <else/>
        <div class="p10"><img style='width:100%' src="/static/weixin/images/index/receive_bg_title.png" alt=""></div>
        <volist name='order_details' id='item' >
        <div class="order_form" style="padding:0px;margin:0px;border-width:0px;background:none;box-shadow:0 0 0">
        <div class="con">
            <p class="ware_pic"><a href="{:u('item/index',array('id'=>$item['itemId']))}" ><img src="{:attach(get_thumb($item['img'], '_b'), 'item')}" height="80" width="80"></a></p>
            <p class="ware_text"><a href="{:u('item/index',array('id'=>$item['itemId']))}">{$item.title}</a><br><span class="attr"></span></p>
            <p class="price">价格: <span>¥{$order.order_sumPrice}</span></p>
            <!-- <p class="amount">数量: <span>{$item.quantity}</span></p>
            <p class="amount"><php>if($item['color']){</php>颜色: <span>{$item['color']}</span><php>}</php><php>if($item['size']){</php>&nbsp;尺码: <span>{$item['size']}</span><php>}</php></p> -->
            
        </div>
        </volist>
        

        <div class="order_address_list">
        <script type="text/javascript" src="__STATIC__/weixin/js/mlselection.js" charset="utf-8"></script>
         <!-- <script type="text/javascript" src="__STATIC__/weixin/js/area.js" charset="utf-8"></script>-->
        <script type="text/javascript" src="__STATIC__/weixin/js/jquery_003.js" charset="utf-8"></script>
        <script type="text/javascript" src="__STATIC__/weixin/js/dialog.js" id="dialog_js" charset="utf-8"></script>
        <link href="__STATIC__/weixin/css/dialog.css" rel="stylesheet" type="text/css">
        <script type="text/javascript" src="__STATIC__/weixin/js/jquery.js" id="dialog_js" charset="utf-8"></script>
        <script type="text/javascript" language="javascript" src='__STATIC__/weixin/js/dizhi2.js'></script>
<script>
  var PCAD = "{$address_str}";
</script>
<script type="text/javascript" language="javascript" src='__STATIC__/weixin/js/diqu2.js'></script>
        <script>
        var order_type = "{$order_type}";
        if(order_type == 'wosong'){
            $(".order_address_list,.add_title").hide()
        }
        $(function(){
            $('input[name=address_options]').change(function(){
                if($(this).val()==0)
                {
                    $('#address_form').show();
                }else
                {
                    $('#address_form').hide();
                }
            });
            set_address();
        })

        function set_address()
        {
            var addr_id = $("input[name='address_options']:checked").val();

            if(addr_id == 0)
            {

                $('#address_form').show();
            }
            else
            {
                $('#address_form').hide();

            }
        }

        function ordertj()
        {
            var addr_id = $("input[name='address_options']:checked").val();
            if(addr_id == 0 && order_type != 'wosong')
            {
                var consignee=  $.trim($('#consignee').val());
                var address=  $.trim($('#address').val());
                var phone_mob=  $.trim($('#phone_mob').val());
                var sheng=  $.trim($('#s1').val());

                if(consignee=='')
                {
                    alert('请输入收货人姓名');
                    return false;
                }
                if(sheng=='')
                {
                    alert('请选择所在地区');return false;
                }

                if(address=='')
                {
                    alert('请输入详细地址');
                    return false;
                }
                if(phone_mob=='')
                {
                    alert('请输入手机号码');
                    return false;
                }
                if(isNaN(phone_mob))
                {
                    alert('请输入正确的手机号码');return false;
                }
            }
            $('#order_form').submit();

        }
        </script>

      
      <div class="mb20"><img src="__STATIC__/weixin/images/index/address_title.png" alt="" class='w100'></div>
       <form method="POST"  action="{:u('order/share')}" id="order_form" name="order_form"   >
        <input type="hidden" name="orderid" value="{$order.id}">
        <?php if(count($address_list)!=0){ ?>
        
        <volist name='address_list' id='vo' >
        <ul class="receive_add address_item selected_address">
            <li class="radio"><input id="address_{$vo.id}" checked="checked"  name="address_options" value="{$vo.id}" type="radio"></li>
            <li class="particular">{$vo.sheng}&nbsp;{$vo.shi}&nbsp;{$vo.qu}&nbsp;{$vo.address}</li>
            <li class="name">收货人姓名: {$vo.consignee}</li>
            <li class="mobile">手机号码:{$vo.mobile}</li>
        </ul>
       </volist>
        <ul class="new_receive_add address_item">
            <li class="radio">
            <input name="address_options" id="use_new_address" value="0"  type="radio">
            </li><li class="particular">使用新的收货地址</li>
        </ul>    
           
        <ul style="display: none;" class="fill_in_content" id="address_form">
            <!-- <li>
                <p class="title">收货人姓名</p>
                <p><input value="" name="consignee" id="consignee" class="text" type="text"></p>
            </li> -->
            <li>
                <!-- <p class="title">所在地区</p>
                <p></p> -->
                <div id="region">
                 <select name="sheng" id="s1"></select>
                <select name="shi" id="s2"></select>
                <select name="qu" id="s3"></select>
                <select name="business_area"><option value="">--请选择商圈--</option></select>
                <select name="building"><option value="">--请选择大厦--</option></select>
                </div>
                    <script language="javascript">
                                new PCAS("sheng","shi","qu","","","");
            </script>
                <p></p>
            </li>

            <li>
                <p class="title mt10">收货人：
                <input value="" name="consignee" id="consignee" class="text" type="text">
                </p>
            </li>
            <li>
                <p class="title">门牌号：
                <input value="" name="address" id="address" class="text width1" type="text">
                </p>
            </li>
            <li>
                <p class="title">手机号：<input id="phone_mob" name="phone_mob" class="text" type="text"></p>
            </li>
            <li>
                <p class="title">&nbsp;</p>
                <!-- <p>
                    <label>
                        <input value="1" id="save_address" name="save_address" type="checkbox" checked>&nbsp;自动保存收货地址
                        <span class="explain">&nbsp;(&nbsp;选择后该地址将会保存到您的收货地址列表&nbsp;)&nbsp;</span>
                    </label>
                </p> -->
            </li>
        </ul>
        <?php }else{ ?>
           <ul class="new_receive_add address_item">
            <li class="radio">
            <input checked='checked' name="address_options" id="use_new_address" value="0"  type="radio">
            </li><li class="particular">使用新的收货地址</li>
            </ul> 
       
        <ul  class="fill_in_content" id="address_form">
            <!-- <li>
                <p class="title">收货人姓名</p>
                <p><input value="" name="consignee" id="consignee" class="text" type="text"></p>
            </li> -->
            <li>
                <!-- <p class="title">所在地区</p>
                <p></p> -->
                <div id="region">
                 <select name="sheng" id="s1"></select>
                <select name="shi" id="s2"></select>
                <select name="qu" id="s3"></select>
                <select name="business_area"><option value="">--请选择商圈--</option></select>
                <select name="building"><option value="">--请选择大厦--</option></select>
                </div>
                    <script language="javascript">
                                      new PCAS("sheng","shi","qu","","","");
                       </script>
                <p></p>
            </li>

            <li>
                <p class="title mt10">收货人：
                <input value="" name="consignee" id="consignee" class="text" type="text">
                </p>
            </li>
            <li>
                <p class="title">门牌号：<input value="" name="address" id="address" class="text width1" type="text"></p>
            </li>
            <li>
                <p class="title">手机号：<input id="phone_mob" name="phone_mob" class="text" type="text"></p>
                <!-- <p><input value="" id="phone_mob" name="phone_mob" class="text" type="text"></p> -->
            </li>
            <li>
                <p class="title">&nbsp;</p>
                <!-- <p>
                    <label>
                        <input value="1" id="save_address" name="save_address" type="checkbox">&nbsp;自动保存收货地址
                        <span class="explain">&nbsp;(&nbsp;选择后该地址将会保存到您的收货地址列表&nbsp;)&nbsp;</span>
                    </label>
                </p> -->
            </li>
        </ul>
        <?php } ?>
        
    </div>              
    

    <div id="content" style="min-height:1px;padding:15px">
        <img onclick="window.location.href='{:u('user/addaddress')}'" src="/static/weixin/images/index/open_btn.png" style="width:40%">
        <img onclick="save_address()" id='submit-address-btn' src="/static/weixin/images/index/submit_btn.png" style="margin-left:18%;width:40%">
    </div>
    </form>
    <script>
        $(function(){

            $('input[name=address_options]').change(function(){
                if($(this).val()==0)
                {
                    $('#address_form').show();
                }else
                {
                    $('#address_form').hide();
                }
            });
            set_address();
        })

        function set_address()
        {
            var addr_id = $("input[name='address_options']:checked").val();

            if(addr_id == 0)
            {

                $('#address_form').show();
            }
            else
            {
                $('#address_form').hide();

            }
        }
        function save_address(){
            var addr_id = $("input[name='address_options']:checked").val();
            if(addr_id == 0)
            {
                var consignee=  $.trim($('#consignee').val());
                var address=  $.trim($('#address').val());
                var phone_mob=  $.trim($('#phone_mob').val());
                var sheng=  $.trim($('#s1').val());

                if(consignee=='')
                {
                    alert('请输入收货人姓名');
                    return false;
                }
                if(sheng=='')
                {
                    alert('请选择所在地区');return false;
                }

                if(address=='')
                {
                    alert('请输入详细地址');
                    return false;
                }
                if(phone_mob=='')
                {
                    alert('请输入手机号码');
                    return false;
                }
                if(isNaN(phone_mob))
                {
                    alert('请输入正确的手机号码');return false;
                }
            }
            $('#order_form').submit()
        }
        //$("#submit-address-btn").submit()
    </script>

        
    </if>
</div>
</if>

<script>
var imgUrl = "http://" + window.location.host + "<php> echo attach(get_thumb($order_details[0]['img'], '_b'), 'item')</php>";
var lineLink = window.location.href;
<if condition="$order.type eq 'songwo'">
var descContent = "没钱了，土豪帮帮忙吧！";
<else/>
var descContent = "这是一份满满爱意的问候，希望能给你带来好心情~";
</if>
var shareTitle = "{$order_details[0]['title']}";
var appid = "<php>echo C('WEIXIN_APPID')</php>";//填入你的appid

// function shareFriend() {
//     WeixinJSBridge.invoke('sendAppMessage',{
//         "appid": appid,
//         "img_url": imgUrl,
//         "img_width": "640",
//         "img_height": "640",
//         "link": lineLink,
//         "desc": descContent,
//         "title": shareTitle
//     }, 
//     function(res) {
//         _report('send_msg', res.err_msg);
//     })
// }


  // 注意：所有的JS接口只能在公众号绑定的域名下调用，公众号开发者需要先登录微信公众平台进入“公众号设置”的“功能设置”里填写“JS接口安全域名”。 
  // 如果发现在 Android 不能分享自定义内容，请到官网下载最新的包覆盖安装，Android 自定义分享接口需升级至 6.0.2.58 版本及以上。
  // 完整 JS-SDK 文档地址：http://mp.weixin.qq.com/wiki/7/aaa137b55fb2e0456bf8dd9148dd613f.html
  wx.ready(function () {
    wx.onMenuShareAppMessage({
      title: shareTitle,
      desc: descContent,
      link: lineLink,
      imgUrl: imgUrl,
      trigger: function (res) {
        //alert('用户点击发送给朋友');
      },
      success: function (res) {
        window.location.href = '{:u("order/main")}'
      },
      cancel: function (res) {
        //alert('已取消');
      },
      fail: function (res) {
        alert(JSON.stringify(res));
      }
    });
    //alert('已注册获取“发送给朋友”状态事件');
  });
</script>
<include file="public:footer" />
</body>
</html>